package com.jxl.controller;


import com.jxl.entity.dto.ScheduleDTO;
import com.jxl.entity.query.SchedulePageQuery;
import com.jxl.entity.vo.PageResponse;
import com.jxl.entity.vo.ResponseResult;
import com.jxl.entity.vo.ScheduleVO;
import com.jxl.service.IScheduleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 排班表 前端控制器
 * </p>
 *
 * @author 金小梁
 * @since 2025-06-09
 */
@Api(tags = "排班接口")
@RestController
@RequestMapping("/schedule")
public class ScheduleController {
    @Autowired
    private IScheduleService scheduleService;


    @ApiOperation("分页查询排班")
    @PostMapping("/querySchedules")
    public ResponseResult<PageResponse<ScheduleVO>> querySchedules(@RequestBody SchedulePageQuery schedulePageQuery) {
        PageResponse<ScheduleVO> pageResponse = scheduleService.querySchedules(schedulePageQuery);
        return ResponseResult.success(pageResponse);
    }


    @ApiOperation("新增排班")
    @PostMapping("/addSchedule")
    public ResponseResult addSchedule(@RequestBody ScheduleDTO scheduleDTO) {
        scheduleService.addSchedule(scheduleDTO);
        return ResponseResult.success();
    }


    @ApiOperation("删除排班")
    @DeleteMapping("/deleteSchedule")
    public ResponseResult deleteSchedule(@RequestBody List<Long> ids) {
        scheduleService.removeByIds(ids);
        return ResponseResult.success();
    }


    @ApiOperation("修改排班")
    @PutMapping("/editSchedule")
    public ResponseResult updateSchedule(@RequestBody ScheduleDTO scheduleDTO) {
        scheduleService.updateSchedule(scheduleDTO);
        return ResponseResult.success();
    }



}
